home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / tex / texsrc.arc / TEX.H < prev    next >
C/C++ Source or Header  |  1988-09-14  |  5KB  |  164 lines

  1. /*
  2.  * Main include file for TeX in C.
  3.  * You shouldn't have to change anything in this file except the initial
  4.  * #define's/#undef's, and the default search paths.
  5.  *
  6.  * Tim Morgan   December 23, 1987
  7.  * hacked up by David Dermott for MEGAMAX-c
  8.  */
  9.  
  10. #include <stdio.h>
  11. #define void int
  12. /*#undef    TRIP*/        /* Create an initex which can run the trip test */
  13. /*#if defined(INITEX) || defined(TRIP)*/
  14. #ifdef TRIP
  15. #define INITEX
  16. #endif
  17. #ifdef INITEX
  18. #define    STAT        /* Want stats-gathering code */
  19. #endif
  20. /*#undef    DEBUG    */    /* Want debugging code */
  21.  
  22. /*
  23.  * Search paths for TeX
  24.  */
  25.  
  26. /*
  27.  * These are the default paths to use, if the user doesn't
  28.  * override with an environment variable or a rooted path
  29.  */
  30. /*#define    TEXFORMATS    ".:/usr/uci/lib/tex82"
  31. #define    TEXINPUTS    ".:/usr/uci/lib/tex82"
  32. #define    TEXFONTS    ".:/usr/uci/lib/fonts/tfm"
  33. #define    TEXPOOL        ".:/usr/uci/lib/tex82"
  34. */
  35. #define    TEXFORMATS    ".;\\tex"
  36. #define    TEXINPUTS    ".;\\tex\\inputs"
  37. #define    TEXFONTS    ".;\\tex\\tfm"
  38. #define    TEXPOOL        ".;\\tex"
  39.  
  40. /* These are used in TeX.web, the change files, and tex.h-defined macros */
  41. #define    inputpathspec    1
  42. #define    readpathspec    2
  43. #define    fontpathspec    3
  44. #define    fmtpathspec    4
  45. #define    poolpathspec    5
  46.  
  47. extern char *strcpy(), *strcat();    /* From the C library */
  48.  
  49. /*
  50.  * Global routines implemented as macros, plus some type coercion stuff.
  51.  */
  52.  
  53. /* This is a workaround to a casting bug in the Sequent Dynix 2.1 C compiler */
  54. #ifndef    sequent
  55. #define    toint(x)    ((integer) (x))
  56. #else
  57. #define    toint(x)    ztoint((integer)(x))
  58. #endif
  59.  
  60. /*
  61.  * Next, efficiency for Unix systems: use write() instead of stdio
  62.  * to write to the dvi file.
  63.  */
  64. /* #ifndef    UNIX */
  65. #ifndef    VMS
  66. #define    writedvi(a,b)  dwrite((char *) &dvibuf[a], (int)sizeof(dvibuf[a]), (int)(b-a+1), dvifile)
  67. /*#define    writedvi(a,b)    (void) fwrite((char *) &dvibuf[a], sizeof(dvibuf[a]), (int)(b-a+1), dvifile)
  68. */
  69. #else    /* unix */
  70. #define    writedvi(a,b)    (void) write(fileno(dvifile), (char *) &dvibuf[a],(int)(b-a+1))
  71. /* #define    dumpcore    abort */
  72. #endif    /* unix */
  73.  
  74. #define    abs(x)        ((x>=0)?(x):(-(x)))
  75. #define    fabs(x)        ((x>=0.0)?(x):(-(x)))
  76. #define    Fputs(stream, s)    (void) fputs(s, stream)
  77. #define    vstrcpy(a,b)        (void) strcpy((a), (b))
  78. #define    inputln(stream, flag)    zinputln(stream)
  79. char zinputln();    /* Get function return type correct=>boolean */
  80. /*#define    dumpthings(base,len)    (void) fwrite((char *) &(base), sizeof(base), (int)(len), fmtfile)
  81. #define    undumpthings(base,len)    (void) fread((char *) &(base), sizeof(base), (int)(len), fmtfile) 
  82. */
  83. /* MEGAMAX fwrite fread only allow len<32767 */
  84. #define    dumpthings(base,len)     fmtwrite((char *) &(base), sizeof(base), (long)(len), fmtfile)
  85. #define    undumpthings(base,len)     fmtread((char *) &(base), sizeof(base), (long)(len), fmtfile)
  86.  
  87. #define    termflush(t)    (void) fflush(t)
  88. #define    eof(x)        feof(x)
  89. #define    incr(x)        ++x
  90. #define    decr(x)        --x
  91. #define    uexit(x)    exit(x)
  92. #define    odd(x)        ((x) & 1)
  93. #define    aopenin(f, p)    Openin(&(f), p,"r")
  94. #define    bopenin(f)    Openin(&(f), fontpathspec,"br") /* Only used for TFMs */
  95. #define    wopenin(f)    Openin(&(f), fmtpathspec,"br")  /* Only used for FMTs */
  96. #define    aopenout(f)    Openout(&(f),"w") /* Always open outputs in cwd */
  97. #define    bopenout(f)     Openout(&(f),"bw")
  98. #define    wopenout(f)    Openout(&(f),"bw")
  99. #define    aclose(f)    (void) fclose(f)
  100. #define    bclose(f)    (void) fclose(f)
  101. #define    wclose(f)    (void) fclose(f)
  102. #define    addr(x)        ((char *) &(x))
  103. #define    read(f, c)    (c = getc(f))
  104. #define    input        stdin
  105. #define    output        stdout
  106. #define    true        1
  107. #define    false        0
  108. #define    chr(x)        (x)
  109. #define    trunc(x)    toint(x)
  110. #define    round(x)    toint(x + 0.5)
  111. #define    dateandtime(i,j,k,l)    get_date_and_time(&(i), &(j), &(k), &(l))
  112. #define    putfmtword(x)    (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
  113. #define    putfmthh(x)    (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
  114. #define    putfmtqqqq(x)    (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
  115. #define    putfmtint(x)    putlw((long)x,fmtfile)
  116. #define    getfmtword(x)    (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
  117. #define    getfmthh(x)    (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
  118. #define    getfmtqqqq(x)    (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
  119. #define    getfmtint(x)    (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
  120.  
  121. /*
  122.  * Global Types --- many simulate equivalent Pascal types
  123.  */
  124. typedef    float    real;
  125. typedef FILE    *alphafile, *bytefile, *wordfile;
  126. typedef    long    integer;
  127. typedef    char    boolean;
  128. typedef    unsigned char quarterword;
  129. typedef    unsigned int halfword;
  130. typedef float glueratio;/* to save space in the mem structure. */
  131. typedef char *ccharpointer;
  132.  
  133. /*
  134.  * Global Datastructures too hard to translate automatically from Pascal.
  135.  */
  136.  
  137. typedef union {
  138.     struct {
  139.     halfword RH, LH;
  140.     } v;
  141.     struct {
  142.     halfword junk_space;    /* Make B0,B1 overlap LH in memory */
  143.     quarterword B0, B1;
  144.     } u;
  145. } twohalves;
  146. #define    b0    u.B0
  147. #define    b1    u.B1
  148.  
  149. typedef struct {
  150.     struct {
  151.     quarterword B0;
  152.     quarterword B1;
  153.     } u;
  154.     quarterword b2;
  155.     quarterword b3;
  156. } fourquarters;
  157.  
  158. typedef union {
  159.     integer cint;
  160.     glueratio gr;
  161.     twohalves hh;
  162.     fourquarters qqqq;
  163. } memoryword;
  164.